void display(int a[])
{

	int i = 0; 

	printf("[");

	for (i = 0; i < size_numbers_entered; i++)
		printf("%d ", a[i]);

	printf("] \n");
	
	
	
	
		
}




void insert(int a[])
{
    int x,k,l;

    printf("Enter the number you want to insert and the index with a comma in between \n ");
    scanf("%d,%d",&x,&l);
   
   
     
    int b[100],i,j ;
    for(i=0;i<size_numbers_entered;i++)
    {
        b[i]=a[i];
    }
    a[l]=x;
    size_numbers_entered++;
    a=realloc(a,sizeof(int)*size_numbers_entered);

    for(j=l+1;j<size_numbers_entered;j++)
    {
        a[j]=b[j-1];
    }
     
    display(a);

}

// This code is to use the insert function with inplace insertion. 

/*
	int i, x, k, temp, temp1;

	printf("Enter the number you want to insert and the index with a comma in between \n ");
	scanf("%d,%d", &x, &i);

	temp1 = a[size_numbers_entered-1];              
	for (k = i; k < size_numbers_entered; k++) {                  
		temp = a[i + 1];
		a[i + 1] = a[i];
	}
	a[i] = x;
	a[size_numbers_entered] = temp1;

	printf(" You inserted %d at %d position \n", x, i);

	printf("[");

	for (k = 0; k < size_numbers_entered + 1; k++) {
		printf(" %d", a[i]);
	}
	printf("]");

*/





int main()
{
	int *a;
	int option=1, number, i=0, counter;
	char string[10], string2[10];
	

	
		printf("\\WELCOME TO PYTHON LIST IMPLEMENTATION/    \n");
	
	/*
		a=malloc(16);
		int num;
		char cont;
	
		do{ 
		printf("Please enter an number");                        This code is an alternative to the code written below . In this the user will 										 not be asked for an input , that is how many numbers do you want to enter
		scanf("%d",&num);
		
		a[i] = num;
		i++;
		
		printf("Do you want to continue");		
		scanf("%c",cont);
		}
		while(strcmp(cont,'y')==0);
		
		size_numbers_entered=i;
	
	
	*/
	
	
	// code for user input
	
		printf("Enter how many numbers do you want to enter ");
		scanf("%d", &size_numbers_entered);
		a=malloc(sizeof(int)*size_numbers_entered);  //Implementation by dynamic allocation
		
		//int a[size_numbers_entered+5];    The Code was implemented by static allocation earlier . This statement will be used for static 								implementation
		
	

		for (i = 0; i < size_numbers_entered; i++) {
			printf("Enter an number ");
			scanf("%d", &number);
			a[i] = number;
			
		}
		printf("\t\t\t\tYour list is \n\n");
		display(a);
		printf("\t\t\t\tYour list has  %d elements \n\n",size_numbers_entered);
		
		
		do {
		printf(" Which function do you want to implement - \n ");
		printf(" \n------------------------------------------------------------------------------------------ \n");
		printf("       	           0)        Display\n");
		printf("                   1)        Append\n");
		printf("                   2)        Extend\n");
		printf("                   3)        Pop\n");
		printf("                   4)        Remove\n");
		printf("                   5)        Index\n");
		printf("                   6)        Insert\n");
		printf("                   7)        list_size\n");
		printf("                   8)        Sort\n");
		printf("                   9)        Reverse\n");
		printf("                   10        Count\n");
		printf("                   11)       Check if value in list\n");
		printf("                   12)       Add more values\n");
		printf("                   13)       Exit\n");
		
		printf
		    (" \n    ------------------------------------------------------------------------------------------   \n  ");

		printf("\t\t\t\t Please enter an option \t");
		scanf("%d", &option);
		
		//code for choosing which function  

		switch (option) {
		case 0:
			{
			display(a);
		
			}
			break;
*/  /*		case 1:
			append(a);
			break;
		case 2:
			extend(a);
			break;
		case 3:
			pop(a);
			break;
		case 4:
			
			removefunc(a);
			break;
		case 5:
			indexx(a);
			break;     */ 
 		case 6:
			insert(a);
			break;/*
		case 7:
			list_size(a);
			break;
		case 8:
			sort(a);
			break;
		case 9:
			reverse(a);
			break;
		case 10:
			count(a);
			break;
		case 11:
			check_value_in_list(a);
			break;
		case 12:
			add_values(a);
			break;
			
		case 13:
			exit(0);

		}
*/
		printf("\nType 'again' to run the program once again \n");
		scanf("%s", string);
	}
	while (strcmp(string, "again") == 0);
	return 0;

}
